﻿<?php
class AnnounceController extends Controller
{
	public $url_announce;
	public $announcebehavior;
	private $user_id;
	private $user_name;
	/*
	 * 
	 */
	protected function beforeAction($action)
	{
		parent::beforeAction($action);
		
		return true;
	}
	/*
	 * 
	 */
	public function actionindex()
	{
		echo yii::app()->request->baseUrl;
	}
	/**
	 * 
	 */
	public function actionadd()
	{
		$userid=1;
		$params=array();
		$params['userid']=isset($userid)?$userid:null;
		$params['username']=isset($_REQUEST['username'])?$_REQUEST['username']:null;
		$params['subject']=isset($_REQUEST['subject'])?$_REQUEST['subject']:null;
		$params['content']=isset($_REQUEST['content'])?$_REQUEST['content']:null;
		$params['sort']=isset($_REQUEST['sort'])?$_REQUEST['sort']:null;
		$params['link']=isset($_REQUEST['link'])?$_REQUEST['link']:null;
		if(!empty($params['subject'])&&!empty($params['content'])&&!empty($params['userid']))
		{
			$this->announcebehavior = new AnnounceBehaviors();	
			$flag=$this->announcebehavior->create($params);
			if($flag==true)
			{
				echo "发表成功";
				return 1;
			}
				//$this->redirect('ok',"没有添加成功",500);
			else
			{
				echo "发表失败";
				return 0;
			}
				//$this->redirect("error");
		}
		$this->render('add');
		
		
	}
	public function actionok()
	{
		$this->render('ok');
	}
	public function actionerror()
	{
		$this->render('error');
	}
	public function actionList()
	{
		$this->an;
	}
}